import request from "@/utils/http";

/**
 * 小程序登录
 * @param {string} encryptedData 加密的手机号信息 getphonenumber事件回调中获取
 * @param {string} iv 加密相关 getphonenumber事件回调中获取
 * @param {string} code 通过 wx.login() 获取
 */
export const loginByWXAPI = (data) => {
  return request({
    url: "/login/wxMin",
    method: "POST",
    data,
  });
};
export const loginByTestPhoneAPI = (phoneNumber) => {
  return request({
    url: "/login/wxMin/simple",
    method: "post",
    data: {
      phoneNumber,
    },
  });
};
/** 获取个人资料 */
export const getProfileAPI = () => {
  return request({
    url: "/member/profile",
  });
};
/** 上传头像 */
export const uploadPhotoAPI = (filePath) => {
  return uni.uploadFile({
    url: "/member/profile/avatar",
    // 💥💥 不需要写post
    name: "file",
    // 💥💥 注意参数是一个临时路径
    filePath,
  });
};
// 修改用户信息api
export const updateProfileAPI = (data) => {
  return request({ url: "/member/profile", method: "put", data });
};
